package com.bw.base.net.net

import com.bw.base.net.entity.AddAddressEntity
import com.bw.base.net.entity.AddCarEntity
import com.bw.base.net.entity.AddressEntity
import com.bw.base.net.entity.AllKanJiaEntity
import com.bw.base.net.entity.CarEntity
import com.bw.base.net.entity.CateEntity
import com.bw.base.net.entity.CreateOrderEntity
import com.bw.base.net.entity.GetPreOrderEntity
import com.bw.base.net.entity.GoodsEntity
import com.bw.base.net.entity.IndexEntity
import com.bw.base.net.entity.KanJiaEntity
import com.bw.base.net.entity.LoginEntity
import com.bw.base.net.entity.MyQuanEntity
import com.bw.base.net.entity.OrderEntity
import com.bw.base.net.entity.PayEntity
import com.bw.base.net.entity.PreOrderEntity
import com.bw.base.net.entity.QuanEntity
import com.bw.base.net.entity.Res
import com.bw.base.net.entity.SendCodeEntity
import com.bw.base.net.entity.TeamEntity
import com.bw.base.net.entity.UploadEntity
import com.bw.base.net.entity.UserEntity
import com.bw.base.net.entity.XqEntity
import com.bw.base.net.param.ParamAddAddress
import com.bw.base.net.param.ParamCreateOrder
import com.bw.base.net.param.ParamPay
import com.bw.base.net.param.ParamPreOrder
import okhttp3.MultipartBody
import okhttp3.RequestBody
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.Multipart
import retrofit2.http.POST
import retrofit2.http.Part
import retrofit2.http.Path
import retrofit2.http.Query

interface ApiService {
    @POST(Cons.SEND_CODE_URL)
    suspend fun sendCode(@Query(Cons.PARAM_PHONE)phone:String):Res<SendCodeEntity>
    @POST(Cons.LOGIN_CODE_URL)
    suspend fun loginCode(@Body body:RequestBody):Res<LoginEntity>
    @POST("/api/front/register/reset")
    suspend fun changer(@Body body:RequestBody):Res<Boolean>
    @GET(Cons.USER_URL)
    suspend fun user():Res<UserEntity>
    @GET(Cons.INDEX_URL)
    suspend fun index():Res<IndexEntity>
    @GET(Cons.INDEX_GOODS_URL)
    suspend fun indexGoods(@Path("type")type:Int,@Query("limit")limit:Int,@Query("page")page:Int):Res<GoodsEntity>
    @GET(Cons.GOODS_URL)
    suspend fun search(@Query("keyword")keyword:String,@Query("limit")limit:Int,@Query("page")page:Int):Res<GoodsEntity>
    @GET(Cons.QUAN_URL)
    suspend fun quan(@Query("limit")limit:String,@Query("page")page:String,@Query("type")type:String):Res<QuanEntity>
    @POST(Cons.QUAN_RECEIVE_URL)
    suspend fun quanReceive(@Body body: RequestBody):Res<String?>
    @POST(Cons.ADD_ADDRESS_URL)
    suspend fun addAddress(@Body paramAddAddress: ParamAddAddress):Res<AddAddressEntity>
    @GET(Cons.ADDRESS_URL)
    suspend fun address(@Query("limit")limit: Int,@Query("page")page: Int): Res<AddressEntity>
    @GET("/api/front/bargain/index")
    suspend fun kanjia(): Res<KanJiaEntity>
    @GET("/api/front/combination/list")
    suspend fun team(@Query("limit")limit:Int,@Query("page")page:Int): Res<TeamEntity>
    @GET("/api/front/bargain/index")
    suspend fun allKanjia(): Res<AllKanJiaEntity>
    @GET(Cons.XQ_URL)
    suspend fun  xq(@Path("id")id:Int,@Query("type")type: String):Res<XqEntity>
    @POST(Cons.ADD_CAR_URL)
    suspend fun addCar(@Body body: RequestBody): Res<AddCarEntity>
    @GET(Cons.CAR_URL)
    suspend fun car(@Query("isValid")isValid: String,@Query("limit")limit:String,@Query("page")page:String): Res<CarEntity>
    @POST(Cons.UPDATE_CAR_URL)
    suspend fun updateCar(@Query("id")id: Int,@Query("number")number: Int): Res<String?>
    @POST(Cons.DELETE_CAR_URL)
    suspend fun deleteCar(@Query("ids")ids: Array<Int>): Res<String?>
    @GET(Cons.CATEGORY_URL)
    suspend fun category():Res<CateEntity>
    @POST("/api/front/collect/add")
    suspend fun love(@Body body: RequestBody): Res<String?>
    @POST("/api/front/collect/cancel/{proId}")
    suspend fun noLove(@Path("proId")proId:Int): Res<String?>
    @GET("/api/front/products")
    suspend fun categoryGoods(@Query("cid")cid: Int,@Query("limit")limit: Int,@Query("page")page: Int): Res<GoodsEntity>
    @GET(Cons.GOODS_URL)
    suspend fun cateXq(@Query("cid")cid: Int,@Query("keyword")keyword: String,@Query("limit")limit: Int,
                       @Query("news")news: Boolean,@Query("page")page: Int,@Query("priceOrder")priceOrder: String,@Query("salesOrder")salesOrder: String): Res<GoodsEntity>
    @POST("/api/front/order/pre/order")
    suspend fun preOrder(@Body paramPreOrder: ParamPreOrder): Res<PreOrderEntity>
    @GET("/api/front/order/load/pre/{preOrderNo}")
    suspend fun getPreOrder(@Path("preOrderNo") preOrderNo: String):  Res<GetPreOrderEntity>
    @POST("/api/front/order/create")
    suspend fun createOrder(@Body paramCreateOrder: ParamCreateOrder): Res<CreateOrderEntity>
    @POST("/api/front/pay/payment")
    suspend fun pay(@Body paramPay: ParamPay): Res<PayEntity>
    @GET("/api/front/order/list")
    suspend fun order(@Query("type")type: String,@Query("limit")limit: Int,@Query("page")page: Int): Res<OrderEntity>
    @Multipart
    @POST("/api/front/user/upload/image")
    suspend fun upload(@Query("model")model: String,@Part part: MultipartBody.Part,@Query("pid")pid: String): Res<UploadEntity>
    @GET("/api/front/coupon/list")
    suspend fun myQuan(@Query("limit")limit:String,@Query("page")page:String,@Query("type")type:String): Res<MyQuanEntity>
}